package com.qijian.maindata.domain.query;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.annotation.TableName;
import com.qijian.common.utils.mybatis.WhereType;
import com.qijian.common.utils.mybatis.WhereTypeEnum;
import lombok.Data;
import lombok.ToString;

import java.util.Date;
import java.util.List;
import java.util.Set;


/**
 * 量具对象 查询条件类
 *
 * @author qijian
 * @date 2024-05-07
 */

@Data
@ToString
@TableName("main_ledger_gauge")
public class LedgerGaugeQuery {

    @WhereType(filed = "id")
    private Long id;
    @WhereType(filed = "id", type = WhereTypeEnum.IN)
    private Set<Long> ids;
    @WhereType(filed = "factory_area_id")
    private Long factoryAreaId;
    @WhereType(filed = "factory_area",type = WhereTypeEnum.LIKE)
    private String factoryArea;
    @WhereType(filed = "type",type = WhereTypeEnum.LIKE)
    private String type;
    @WhereType(filed = "name",type = WhereTypeEnum.LIKE)
    private String name;
    @WhereType(filed = "spec",type = WhereTypeEnum.LIKE)
    private String spec;
    @WhereType(filed = "local_no",type = WhereTypeEnum.LIKE)
    private String localNo;
    @WhereType(filed = "out_no",type = WhereTypeEnum.LIKE)
    private String outNo;
    @WhereType(filed = "precise")
    private String precise;
    @WhereType(filed = "period_type")
    private String periodType;

    @WhereType(filed = "inspection_date",type = WhereTypeEnum.BETWEEN)
    private String[] inspectionDate;

    @WhereType(filed = "next_inspection_date",type = WhereTypeEnum.BETWEEN)
    private String[] nextInspectionDate;

    @WhereType(filed = "inspection_type")
    private String inspectionType;
    @WhereType(filed = "manage_style",type = WhereTypeEnum.LIKE)
    private String manageStyle;
    @WhereType(filed = "use_dept_id")
    private Long useDeptId;
    @WhereType(filed = "use_dept_name",type = WhereTypeEnum.LIKE)
    private String useDeptName;
    @WhereType(filed = "remark")
    private String remark;


    @WhereType(filed = "factory_area_id")
    private Long itemClassifyId;
    @WhereType(filed = "local_no")
    private String localNoEq;


    @WhereType(filed = "update_time")
    private Date updateTime;

    @WhereType(fields={"main_ledger_gauge.factory_area","main_ledger_gauge.type",
            "main_ledger_gauge.name","main_ledger_gauge.spec",
            "main_ledger_gauge.local_no",
            "main_ledger_gauge.out_no",
            "main_ledger_gauge.precise",
            "main_ledger_gauge.period_type",
            "main_ledger_gauge.inspection_type",
            "main_ledger_gauge.manage_style",
            "main_ledger_gauge.use_dept_name",
            "main_ledger_gauge.remark"
    },type = WhereTypeEnum.LIKE)
    private String condition;

    //正常
    @WhereType(func = "TIMESTAMPDIFF(DAY,NOW(),next_inspection_date) >=30 ")
    private Boolean isNormal;

    //+
    @WhereType(func = "TIMESTAMPDIFF(DAY,NOW(),next_inspection_date) >=0 and TIMESTAMPDIFF(DAY,NOW(),next_inspection_date)< 30 ")
    private Boolean isPlus;

    //-
    @WhereType(func = "TIMESTAMPDIFF(DAY,NOW(),next_inspection_date) < 0 ")
    private Boolean isMinus;


    @WhereType(func = " (use_dept_name IS NULL OR use_dept_name = '' )")
    private Boolean useDeptNameEqOther;

    @WhereType(func = " (DATE_FORMAT(next_inspection_date, '%Y-%m') = {1} or main_ledger_gauge.id in (select source_id from main_ledger_gauge_record where DATE_FORMAT(next_inspection_date, '%Y-%m') = {1} ))")
    private String ym;

    @WhereType(ignore = true)
    private Long userId;

    @WhereType(filed = "manage_style",type = WhereTypeEnum.EQ)
    private String manageStyleNew;

    @WhereType(ignore = true)
    private Boolean flag;

}
